home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pcl4c341.zip / DIR_IO.C < prev    next >
Text File  |  1992-12-24  |  2KB  |  92 lines

  1. /*
  2. **  DIR_IO.C
  3. **
  4. **  Compile with Microsoft C, Borland Turbo C, or MIX Power C.  You may
  5. **  need to modify the following code for your specfic compiler. Some
  6. **  older versions of Microsoft C do not support directory I/O.
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <dos.h>
  11.  
  12. #ifndef FALSE
  13. #define FALSE 0
  14. #endif
  15.  
  16. #ifndef TRUE
  17. #define TRUE !FALSE
  18. #endif
  19.  
  20. /*** define compiler specfic includes ***/
  21.  
  22. #ifdef __POWERC
  23. /* MIX Power C compiler */
  24. #define TURBO_OR_POWERC
  25. #include <direct.h>
  26. #endif
  27.  
  28. #ifdef __TURBOC__
  29. /* Borland Turbo C compiler */
  30. #define TURBO_OR_POWERC
  31. #include <dir.h>
  32. #endif
  33.  
  34. #ifdef _MSC_VER
  35. /* Microsoft C compiler */
  36. static struct _find_t DirStruct;
  37. #endif
  38.  
  39. #ifdef TURBO_OR_POWERC
  40. static char DTAbuffer[256];
  41. static struct ffblk DirStruct;
  42. #endif
  43.  
  44. /*** FindFirst() and FindNext() functions ***/
  45.  
  46. int FindFirst(FileSpec,Buffer)
  47. char *FileSpec;
  48. char *Buffer;
  49. {
  50. #ifdef _MSC_VER
  51.  if(_dos_findfirst(FileSpec,_A_NORMAL,&DirStruct)==0)
  52.    {
  53.     strncpy(Buffer,DirStruct.name,13);
  54.     return(TRUE);
  55.    }
  56.  return(FALSE);
  57. #endif
  58.  
  59. #ifdef TURBO_OR_POWERC
  60.  setdta(DTAbuffer);
  61.  if( findfirst(FileSpec,&DirStruct,0)==0)
  62.    {
  63.     strncpy(Buffer,DirStruct.ff_name,13);
  64.     return(TRUE);
  65.    }
  66.  return(FALSE);
  67. #endif
  68. }
  69.  
  70. int FindNext(Buffer)
  71. char *Buffer;
  72. {int Result;
  73. #ifdef _MSC_VER
  74. Result = _dos_findnext(&DirStruct);
  75. if(Result==0)
  76.    {
  77.     strncpy(Buffer,DirStruct.name,13);
  78.     return(TRUE);
  79.    }
  80.  return(FALSE);
  81. #endif
  82.  
  83. #ifdef TURBO_OR_POWERC
  84.  if( findnext(&DirStruct)==0 )
  85.    {
  86.     strncpy(Buffer,DirStruct.ff_name,13);
  87.     return(TRUE);
  88.    }
  89.  return(FALSE);
  90. #endif
  91. }
  92.